package com.wangyg.juc.BreadMaker;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by wangyg6 on 2018/7/10.
 */
public class Main {
	public static void main(String[] args) {
		BlockingQueue bq=new ArrayBlockingQueue(100);
		Thread buyer1 = new Thread(new Buyer().setBq(bq), "Buyer1");
		Thread buyer2 = new Thread(new Buyer().setBq(bq), "Buyer2");
		Thread maker1 = new Thread(new Maker().setBq(bq), "Maker1");
		Thread maker2 = new Thread(new Maker().setBq(bq), "Maker2");
		ExecutorService service = Executors.newCachedThreadPool();
		service.execute(buyer1);
		service.execute(buyer2);
		service.execute(maker1);
		service.execute(maker2);
	}
}
